package com.swu.cx.alwayslearning.annotation
import android.app.Activity
import com.swu.cx.alwayslearning.annotation.BindId

object ViewInjectUtil {
    fun injectView(activity: Activity) {
        val clz = activity.javaClass
        for (filed in clz.declaredFields) {
            if (filed.isAnnotationPresent(BindId::class.java)) {
                val viewId = filed.getAnnotation(BindId::class.java)?.id ?: continue
                filed.isAccessible = true
                filed.set(activity, activity.findViewById(viewId))
            }
        }
    }
}